<!doctype html>
<html lang="zh-hans">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">

<!-- css -->
<link rel="stylesheet" href='<?=base_url().'resource/lib/bootstrap/css/bootstrap.min.css'?>'>
<?php if ($showdebug==false): ?>
<link rel="stylesheet" href='<?=base_url().'resource/css/debug.css'?>'>
<?php endif; ?>


<!-- js -->
<script src='<?=base_url().'resource/lib/bootstrap/jquery-2.1.1.min.js'?>'></script>
<script src='<?=base_url().'resource/lib/bootstrap/js/bootstrap.min.js'?>'></script>

<title>test</title>

<script>


/* 缓存测试 */
// window.onload = function() { 
// 	var msg = sessionStorage.getItem("state"); 
// 	alert("测试用户状态为"+msg);
// }

$(function () {
	$("#uid").val(sessionStorage.getItem("uid")); 
	select1();
	$('#S1').bind("change", select2);
	$('#S2').bind("change", select3);
	});

function select1(){
	$.ajax(
	{
	    type: "post",
	    url:'<?=base_url().'index.php/Json_Control/get_address'?>',
	    //url: "/ci/index.php/Json_Control/get_address",  //base_url
	    data: {"type":1},
	    success: function (msg) {
	    	msg = $.parseJSON(msg);
	    	$("#S1").append("<option value="  + "0>" + "</option>");
	        for (var i = 0; i < msg.length; i++) {
	            $("#S1").append("<option value='" +msg[i].provinceId+ "'>" + msg[i].province + "</option>");
	        }
	        select2();
	 
	    }
	})
};


function select2() {
	$("#S2").html("");
	$.ajax(
	{
	    type: "post",
// 	    url: "/ci/index.php/Json_Control/get_address",
	    url:'<?=base_url().'index.php/Json_Control/get_address'?>',
	    data: {"add_code":$('#S1').val(),"type":2},
	    success: function (msg) {
		    //alert($('#S1').val());
	    	msg = $.parseJSON(msg);
	    	$("#S2").append("<option value="  + "0>" + "</option>");
	        for (var i = 0; i < msg.length; i++) {
	            $("#S2").append("<option value=" + msg[i].cityId + ">" + msg[i].city + "</option>");
	        }
	        select3();
	    }
	})
};

function select3() {
	$("#S3").html("");
	$.ajax(
	{
	    type: "post",
// 	    url: "/ci/index.php/Json_Control/get_address",
		url:'<?=base_url().'index.php/Json_Control/get_address'?>',
	    data: { "add_code":$('#S2').val(),"type":3},
	    success: function (msg) {
	    	msg = $.parseJSON(msg);
	    	$("#S3").append("<option value="  + "0>" + "</option>");
	        for (var i = 0; i < msg.length; i++) {
	            $("#S3").append("<option value=" + msg[i].areaId + ">" + msg[i].area+ "</option>");
	        }
	    }
	});
};

function tijiao(){
	var a = parseInt($("#checked_1").val());
	var b = parseInt($("#checked_2").val());
	
	
	if(a+b==2){
		$("#flag").val(1);
    	document.form1.submit();
	}
	else
		alert("请检查输入项");
}     

function check_name(){   //check name
	 $.ajax({ url:'<?=base_url().'index.php/Json_Control/check'?>',
	 		data:{'check_str':$("#name").val(),'type':1}, 
	 		type:'post',
	        success: function(obj){
	        	obj = $.parseJSON(obj);
	        	if(obj.state<1){	//出现错误
// 	   			 	alert(obj.tip);
		        	if(obj.state==-3 || obj.state==-4){
		        		$("#span_11").addClass("glyphicon-warning-sign");
		   			 	$("#span_12").html(obj.tip);
		   				$("#checked_1").val(1);	//同名情况仍然可以通过验证
	
		        	}else{
		   			 	$("#span_11").addClass("glyphicon-remove");
		   			 	$("#span_12").html(obj.tip);
		   				$("#checked_1").val(0);
		        	}
	   			 }else{
	   				$("#span_11").removeClass().addClass("glyphicon form-control-feedback");
	   			 	$("#span_12").html('');
	   			 	$("#checked_1").val(1);
	   			 }
	   						 
	}});   
}    


function check_phone(){   //check name
	 $.ajax({ url:'<?=base_url().'index.php/Json_Control/check'?>',
	 		data:{'check_str':$("#phone").val(),'type':2}, 
	 		type:'post',
	        success: function(obj){
	        	obj = $.parseJSON(obj);
	        	if(obj.state<1){	//出现错误
// 	   			 	alert(obj.tip);
	   			 	$("#span_21").addClass("glyphicon-remove");
	   			 	$("#span_22").html(obj.tip);
	   			 	$("#checked_2").val(0);
	   			 }else{
		   				$("#span_21").removeClass().addClass("glyphicon form-control-feedback");
		   			 	$("#span_22").html('');
		   			 	$("#checked_2").val(1);
		   			 }
	   						 
	}});   
}

function check_idcard(){   //check name
	 $.ajax({ url:'<?=base_url().'index.php/Json_Control/check'?>',
	 		data:{'check_str':$("#idCard").val(),'type':3}, 
	 		type:'post',
	        success: function(obj){
	        	obj = $.parseJSON(obj);
	        	if(obj.state<1){	//出现错误
// 	   			 	alert(obj.tip);
	   			 	$("#span_31").addClass("glyphicon-remove");
	   			 	$("#span_32").html(obj.tip);
	   				 $("#checked_3").val(0);
	   			 }else{
		   				$("#span_31").removeClass().addClass("glyphicon form-control-feedback");
		   			 	$("#span_32").html('');
		   			 	$("#checked_3").val(1);
		   			 }		 
	}});   
}

</script>  
</head>
<body>
<div class="container" >
<div class="row">



<!-- 导航按钮 -->
<ul class="nav nav-pills">
  <li role="presentation"><a href="#">返回首页</a></li>
  <!-- 
  <li role="presentation" class="active"><a href="#">开始注册</a></li>-->
</ul>



<!-- 面板 -->
<div class="panel panel-default">
<div class="panel-heading"><p class="text-info">
    <span class="glyphicon glyphicon-star" aria-hidden="true"></span> 推荐客户基本信息(必填)</p></div>
<div class="panel-body">
<!-- 面板内容 start -->

<form class="form-horizontal" name="form1" action="<?=base_url().'index.php/client_control/add'?>" method="post">
<!-- 表单START -->

<div class="input-group _hide">

<input type="text" class="form-control" id="flag"  name="flag" placeholder="flag" value="<?=isset($flag)?$flag:0;?>" >
<input type="text" class="form-control" id="uid"  name="uid" placeholder="uid" value="<?=isset($uid)?$uid:0;?>" >
<input type="text" class="form-control" id="checked_1"  name="checked_1" placeholder="checked_n" value="" >
<input type="text" class="form-control" id="checked_2"  name="checked_2" placeholder="checked_n" value="" >
</div>



<!-- new start -->
<div class="form-group has-feedback">
<label class="control-label col-xs-3" for="">姓名</label>
<div class="col-xs-9">
<input id="name" name="name" type="text" class="form-control" value="<?=isset($user['name'])?$user['name']:'';?>" onChange="check_name()">
<span id="span_11" class="glyphicon form-control-feedback" aria-hidden="true"></span>
<span id="span_12" class="help-block"></span>
<!-- 
<span class="glyphicon glyphicon-warning-sign form-control-feedback" aria-hidden="true"></span>
<span id="helpBlock" class="help-block">提示信息... </span>  -->
</div>
</div>

<div class="form-group has-feedback">
<label class="control-label col-xs-3" for="">手机</label><div class="col-xs-9">
<input id="phone" name="phone" type="text" class="form-control" 
value="<?=isset($user['phoen'])?$user['phone']:'';?>" onChange="check_phone()" >
<span id="span_21" class="glyphicon form-control-feedback" aria-hidden="true"></span>
<span id="span_22" class="help-block"></span>
</div></div>


<div class="form-group has-feedback">
<label class="control-label col-xs-3" for="">省</label>
<div class="col-xs-9">
<select class="form-control" id="S1" name="provinceId" ></select>
<!-- <span id="span_41" class="glyphicon form-control-feedback" aria-hidden="true"></span> -->
<!-- <span id="span_42" class="help-block"></span> -->
</div>
</div>

<div class="form-group has-feedback">
<label class="control-label col-xs-3" for="">市</label>
<div class="col-xs-9">
<select class="form-control" id="S2" name="cityId" ></select>
<!-- <span id="span_51" class="glyphicon form-control-feedback" aria-hidden="true"></span> -->
<!-- <span id="span_52" class="help-block"></span> -->
</div>
</div>

<div class="form-group has-feedback">
<label class="control-label col-xs-3" for="">区</label>
<div class="col-xs-9">
<select class="form-control" id="S3" name="areaId" ></select>
<!-- <span id="span_61" class="glyphicon form-control-feedback" aria-hidden="true"></span> -->
<!-- <span id="span_62" class="help-block"></span> -->
</div>
</div>
<!-- new end -->



</div><!-- form-group -->   
<!-- 表单END -->
</form>

<!-- 面板内容  end  -->

<div class="panel-footer">
    <div class="row">
        <div class="col-xs-6"></div>
        <div class="col-xs-6"><button type="button" class="btn btn-warning" onClick="tijiao()">
            下一步 <span class="glyphicon glyphicon-arrow-right" aria-hidden="true"></span></button>
        </div>
    </div>
</div>






<!-- </div> -->
<!-- </div> -->
<!-- </body> -->
<!-- </html> -->
